//
//  UIViewLoginAnimated.m
//  attendance
//
//  Created by dgc on 15/7/7.
//  Copyright (c) 2015年 dgc. All rights reserved.
//

#import "LoadingAnimated.h"

@implementation LoadingAnimated
{
    /**
     动画
     */
    UIImageView* loadImageAnimated;
}
-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self)
    {
        _laSize=CGSizeMake(80, 80);
        loadImageAnimated=[[UIImageView alloc] initWithFrame:CGRectZero];
        [self laAnimatedUpdateFrame];
        NSArray* loadImageNames=@[@"progress_1",
                                  @"progress_2",
                                  @"progress_3",
                                  @"progress_4",
                                  @"progress_5",
                                  @"progress_6",
                                  @"progress_7",
                                  @"progress_8"];
        NSMutableArray*  loadImages=[NSMutableArray array];
        for (NSString* loadImageName in loadImageNames)
        {
            [loadImages addObject:[UIImage imageNamed:loadImageName]] ;
        }
        
        loadImageAnimated.image=[UIImage animatedImageWithImages:loadImages
                                                        duration:1.0f];

        [self addSubview:loadImageAnimated];


    }
    return self;
}
/**
 *  更新动画显示
 */
-(void)laAnimatedUpdateFrame
{
    CGPoint superViewCenter=self.center;
    CGPoint loadAnimatedCenter=CGPointMake(superViewCenter.x-_laSize.width/2, superViewCenter.y-_laSize.height/2);
    CGRect  loadImageAnimatedFrame=CGRectMake(loadAnimatedCenter.x, loadAnimatedCenter.y, _laSize.width, _laSize.height);
    loadImageAnimated.frame=loadImageAnimatedFrame;
}
/**
 *  更改显示动画显示尺寸
 */
-(void)setLaSize:(CGSize)laSize
{
    _laSize=laSize;
    [self laAnimatedUpdateFrame];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
